<?php

namespace App\Http\Controllers\Api\O1;

use Biz\Services\Site\SitePageService;
use Biz\Transformers\Site\PageTransformer;
use Laravel\Lumen\Routing\Controller as BaseController;

/**
 * PageController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class PageController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * PageController constructor.
     *
     * @param SitePageService $service
     */
    public function __construct(SitePageService $service)
    {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @param string $page_id
     *
     * @return \Illuminate\Http\Response
     */
    public function show(string $page_id)
    {
        $page = $this->service->findByUid($page_id);
        // Load Translations
        $page->load('translations');

        return new PageTransformer($page);
    }
}
